package com.hishop.coupon.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hishop.common.utils.PageUtils;
import com.hishop.coupon.dao.CouponSpuCategoryRelationDao;
import com.hishop.coupon.entity.CouponSpuCategoryRelationEntity;
import com.hishop.coupon.service.CouponSpuCategoryRelationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Service("couponSpuCategoryRelationService")
public class CouponSpuCategoryRelationServiceImpl extends ServiceImpl<CouponSpuCategoryRelationDao, CouponSpuCategoryRelationEntity> implements CouponSpuCategoryRelationService {

    @Resource
    private CouponSpuCategoryRelationDao couponSpuCategoryRelationDao;

    @Override
    public PageUtils queryPage(String key, Page<CouponSpuCategoryRelationEntity> page) {
        QueryWrapper<CouponSpuCategoryRelationEntity> qw = new QueryWrapper<>();
        if (!key.equals("")) {
            qw.like("id", key)
                    .or().like("coupon_id",key)
                    .or().like("category_id",key)
                    .or().like("category_name",key)
            ;
        }
        return new PageUtils(couponSpuCategoryRelationDao.selectPage(page,qw));
    }

}